from selenium import webdriver
from selenium.webdriver.common.by import By
# TODO 导入Keys类
from selenium.webdriver.common.keys import Keys
import time

# 打开游览器和百度
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
# 搜索框输入关键字
kw = driver.find_element(By.ID,'kw')
kw.send_keys('python')
# 选中关键字
time.sleep(3)
kw.send_keys(Keys.CONTROL,'a')
# 复制
kw.send_keys(Keys.CONTROL,'c')
# 打开360搜索
driver.get('https://www.so.com')
# 定位到搜索框
ipt = driver.find_element(By.ID,'input')
# 粘贴关键字
ipt.send_keys(Keys.CONTROL,'v')
# 点击搜索
time.sleep(2)
driver.find_element(By.ID,'search-button').click()
# 关闭游览器
time.sleep(2)
driver.quit()